<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CentOS 8.3 模拟终端</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Courier New', Courier, monospace;
            background-color: #222;
            color: #00ff00;
            padding: 20px;
            line-height: 1.4;
        }

        .terminal {
            max-width: 90vw;
            margin: 0 auto;
            border: 1px solid #00ff00;
            border-radius: 5px;
            overflow: hidden;
            box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
        }

        /* 滚动条整体样式 */
.terminal-body::-webkit-scrollbar {
    width: 10px;
}

/* 滚动条轨道样式 */
.terminal-body::-webkit-scrollbar-track {
    background: #111;
    border-left: 1px solid #333;
}

/* 滚动条滑块样式 */
.terminal-body::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
    border: 2px solid #111;
}

/* 滚动条滑块 hover 样式 */
.terminal-body::-webkit-scrollbar-thumb:hover {
    background: #33ff33;
}

/* 滚动条按钮样式（上下箭头） */
.terminal-body::-webkit-scrollbar-button {
    display: none;
}

        .terminal-header {
            background-color: #00ff00;
            color: #222;
            padding: 8px 12px;
            font-weight: bold;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .window-controls {
            display: flex;
            gap: 8px;
        }

        .window-controls span {
            display: inline-block;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: #222;
        }

        .terminal-body {
            padding: 15px;
            height: 90vh;
            overflow-y: auto;
            background-color: #111;
        }

        .prompt {
            display: flex;
            align-items: center;
            margin-bottom: 8px;
        }

        .user {
            color: #00ffff;
            font-weight: bold;
        }

        .host {
            color: #ff00ff;
            font-weight: bold;
        }

        .path {
            color: #ffff00;
        }

        .command-input {
            background: none;
            border: none;
            color: #00ff00;
            font-family: 'Courier New', Courier, monospace;
            font-size: 1em;
            padding: 0;
            margin: 0 0 0 8px;
            outline: none;
            width: 100%;
        }

        .output {
            margin-bottom: 12px;
            white-space: pre-wrap;
        }

        .loading {
            display: inline-block;
            animation: blink 1s step-end infinite;
        }

        @keyframes blink {
            from, to { color: transparent }
            50% { color: #00ff00 }
        }

        .success {
            color: #00ff00;
        }

        .error {
            color: #ff0000;
        }

        .info {
            color: #00ffff;
        }
    </style>
</head>
<body>
    <div class="terminal">
        <div class="terminal-header">
            <span>CentOS 8.3 Terminal</span>
            <div class="window-controls">
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div>
        <div class="terminal-body" id="terminal-body">
            <!-- 终端内容将通过 JavaScript 动态生成 -->
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const terminalBody = document.getElementById('terminal-body');
            const commands = [
                'sudo yum update -y',
                'sudo yum install epel-release -y',
                'sudo yum install nginx -y',
                'systemctl start nginx',
                'systemctl status nginx'
            ];
            let currentCommandIndex = 0;

            // 初始化终端
            function initTerminal() {
                addOutput('CentOS Linux 8 (Core)', 'info');
                addOutput('Kernel \\r on an \\m', 'info');
                addOutput('', '');
                addPrompt();
            }

            // 添加输出内容
            function addOutput(text, type = 'default') {
                const outputDiv = document.createElement('div');
                outputDiv.className = `output ${type}`;
                outputDiv.textContent = text;
                terminalBody.appendChild(outputDiv);
                terminalBody.scrollTop = terminalBody.scrollHeight;
            }

            // 添加命令提示符
            function addPrompt() {
                const promptDiv = document.createElement('div');
                promptDiv.className = 'prompt';
                
                const userSpan = document.createElement('span');
                userSpan.className = 'user';
                userSpan.textContent = 'root@centos8';
                
                const hostSpan = document.createElement('span');
                hostSpan.textContent = ':';
                
                const pathSpan = document.createElement('span');
                pathSpan.className = 'path';
                pathSpan.textContent = '/root';
                
                const promptSymbol = document.createElement('span');
                promptSymbol.textContent = '# ';
                
                const input = document.createElement('input');
                input.type = 'text';
                input.className = 'command-input';
                
                promptDiv.appendChild(userSpan);
                promptDiv.appendChild(hostSpan);
                promptDiv.appendChild(pathSpan);
                promptDiv.appendChild(promptSymbol);
                promptDiv.appendChild(input);
                
                terminalBody.appendChild(promptDiv);
                terminalBody.scrollTop = terminalBody.scrollHeight;
                
                // 自动输入并执行命令
                if (currentCommandIndex < commands.length) {
                    const command = commands[currentCommandIndex];
                    typeCommand(input, command, () => {
                        executeCommand(command);
                        currentCommandIndex++;
                    });
                }
            }

            // 模拟打字效果输入命令
            function typeCommand(inputElement, command, callback) {
                let i = 0;
                inputElement.focus();
                
                function typeCharacter() {
                    if (i < command.length) {
                        inputElement.value += command.charAt(i);
                        i++;
                        setTimeout(typeCharacter, 50 + Math.random() * 30);
                    } else {
                        setTimeout(() => {
                            inputElement.blur();
                            callback();
                        }, 500);
                    }
                }
                
                typeCharacter();
            }

            // 执行命令并显示输出
            function executeCommand(command) {
                // 移除输入框
                const promptDiv = terminalBody.lastChild;
                // promptDiv.querySelector('.command-input').remove();
                
                // 根据命令显示不同的输出
                switch(command) {
                    case 'sudo yum update -y':
                        showYumUpdateOutput();
                        break;
                    case 'sudo yum install epel-release -y':
                        showYumInstallEpelOutput();
                        break;
                    case 'sudo yum install nginx -y':
                        showYumInstallNginxOutput();
                        break;
                    // 新增命令：启动 Nginx
                    case 'systemctl start nginx':
                        showSystemctlStartNginxOutput();
                        break;
                    // 新增命令：查看 Nginx 状态
                    case 'systemctl status nginx':
                        showSystemctlStatusNginxOutput();
                        break;
                }
            }

            // 显示 yum update 输出
            function showYumUpdateOutput() {
                const updateOutput = [
                    'Last metadata expiration check: 0:01:23 ago on Mon 01 Jan 2024 12:00:00 AM UTC.',
                    'Dependencies resolved.',
                    '',
                    '================================================================================',
                    ' Package             Architecture Version                  Repository       Size',
                    '================================================================================',
                    'Upgrading:',
                    ' kernel              x86_64       4.18.0-305.3.1.el8_4      baseos         5.7 M',
                    ' kernel-core         x86_64       4.18.0-305.3.1.el8_4      baseos          31 M',
                    ' kernel-modules      x86_64       4.18.0-305.3.1.el8_4      baseos          23 M',
                    ' dnf                 noarch       4.4.2-11.el8_4            baseos         5.7 M',
                    ' dnf-data            noarch       4.4.2-11.el8_4            baseos         157 k',
                    ' etcd                x86_64       3.3.11-2.el8_4            appstream      9.1 M',
                    ' firewalld           noarch       0.9.3-13.el8_4            baseos         543 k',
                    ' firewalld-filesystem noarch     0.9.3-13.el8_4            baseos          48 k',
                    ' firewalld-python    noarch       0.9.3-13.el8_4            baseos         115 k',
                    ' glibc               x86_64       2.28-151.el8              baseos         3.6 M',
                    ' glibc-common        x86_64       2.28-151.el8              baseos          12 M',
                    ' glibc-devel         x86_64       2.28-151.el8              baseos         2.0 M',
                    ' glibc-headers       x86_64       2.28-151.el8              baseos         483 k',
                    ' glibc-langpack-en   x86_64       2.28-151.el8              baseos         810 k',
                    ' kernel-headers      x86_64       4.18.0-305.3.1.el8_4      baseos         4.4 M',
                    ' python3-dnf         noarch       4.4.2-11.el8_4            baseos         3.0 M',
                    ' python3-firewall    noarch       0.9.3-13.el8_4            baseos         288 k',
                    ' python3-libs        x86_64       3.6.8-37.el8              baseos         7.0 M',
                    ' systemd             x86_64       239-45.el8_4.3            baseos         3.5 M',
                    ' systemd-libs        x86_64       239-45.el8_4.3            baseos         513 k',
                    ' systemd-pam         x86_64       239-45.el8_4.3            baseos         643 k',
                    ' systemd-udev        x86_64       239-45.el8_4.3            baseos         1.9 M',
                    ' tar                 x86_64       2:1.30-5.el8              baseos         822 k',
                    ' tzdata              noarch       2021a-1.el8               baseos         495 k',
                    ' yum                 noarch       4.4.2-11.el8_4            baseos         465 k',
                    '',
                    'Transaction Summary',
                    '================================================================================',
                    'Upgrade  26 Packages',
                    '',
                    'Total download size: 117 M',
                    'Downloading Packages:',
                    '[MIRROR] kernel-4.18.0-305.3.1.el8_4.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] kernel-core-4.18.0-305.3.1.el8_4.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] kernel-modules-4.18.0-305.3.1.el8_4.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] dnf-4.4.2-11.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] dnf-data-4.4.2-11.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] etcd-3.3.11-2.el8_4.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] firewalld-0.9.3-13.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] firewalld-filesystem-0.9.3-13.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] firewalld-python-0.9.3-13.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] glibc-2.28-151.el8.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] glibc-common-2.28-151.el8.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] glibc-devel-2.28-151.el8.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] glibc-headers-2.28-151.el8.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] glibc-langpack-en-2.28-151.el8.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] kernel-headers-4.18.0-305.3.1.el8_4.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] python3-dnf-4.4.2-11.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] python3-firewall-0.9.3-13.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] python3-libs-3.6.8-37.el8.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] systemd-239-45.el8_4.3.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] systemd-libs-239-45.el8_4.3.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] systemd-pam-239-45.el8_4.3.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] systemd-udev-239-45.el8_4.3.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] tar-1.30-5.el8.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] tzdata-2021a-1.el8.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] yum-4.4.2-11.el8_4.noarch.rpm: Downloading from centos.mirror.com',
                    '--------------------------------------------------------------------------------',
                    'Total                                           12 MB/s | 117 MB     00:09',
                    'Running transaction check',
                    'Transaction check succeeded.',
                    'Running transaction test',
                    'Transaction test succeeded.',
                    'Running transaction',
                    '  Preparing        :                                                        1/1',
                    '  Upgrading        : kernel-4.18.0-305.3.1.el8_4.x86_64                    1/52',
                    '  Upgrading        : kernel-core-4.18.0-305.3.1.el8_4.x86_64               2/52',
                    '  Upgrading        : kernel-modules-4.18.0-305.3.1.el8_4.x86_64            3/52',
                    '  Upgrading        : tzdata-2021a-1.el8.noarch                             4/52',
                    '  Upgrading        : glibc-common-2.28-151.el8.x86_64                       5/52',
                    '  Upgrading        : glibc-2.28-151.el8.x86_64                              6/52',
                    '  Upgrading        : glibc-langpack-en-2.28-151.el8.x86_64                  7/52',
                    '  Upgrading        : python3-libs-3.6.8-37.el8.x86_64                       8/52',
                    '  Upgrading        : systemd-libs-239-45.el8_4.3.x86_64                     9/52',
                    '  Upgrading        : systemd-pam-239-45.el8_4.3.x86_64                     10/52',
                    '  Upgrading        : systemd-239-45.el8_4.3.x86_64                         11/52',
                    '  Upgrading        : systemd-udev-239-45.el8_4.3.x86_64                   12/52',
                    '  Upgrading        : firewalld-filesystem-0.9.3-13.el8_4.noarch            13/52',
                    '  Upgrading        : firewalld-0.9.3-13.el8_4.noarch                       14/52',
                    '  Upgrading        : python3-firewall-0.9.3-13.el8_4.noarch                15/52',
                    '  Upgrading        : firewalld-python-0.9.3-13.el8_4.noarch                16/52',
                    '  Upgrading        : dnf-data-4.4.2-11.el8_4.noarch                        17/52',
                    '  Upgrading        : dnf-4.4.2-11.el8_4.noarch                             18/52',
                    '  Upgrading        : python3-dnf-4.4.2-11.el8_4.noarch                     19/52',
                    '  Upgrading        : yum-4.4.2-11.el8_4.noarch                             20/52',
                    '  Upgrading        : tar-2:1.30-5.el8.x86_64                               21/52',
                    '  Upgrading        : kernel-headers-4.18.0-305.3.1.el8_4.x86_64            22/52',
                    '  Upgrading        : glibc-headers-2.28-151.el8.x86_64                     23/52',
                    '  Upgrading        : glibc-devel-2.28-151.el8.x86_64                       24/52',
                    '  Upgrading        : etcd-3.3.11-2.el8_4.x86_64                             25/52',
                    '  Cleanup          : etcd-3.3.11-1.el8.x86_64                               26/52',
                    '  Cleanup          : glibc-devel-2.28-127.el8.x86_64                        27/52',
                    '  Cleanup          : glibc-headers-2.28-127.el8.x86_64                      28/52',
                    '  Cleanup          : kernel-headers-4.18.0-240.22.1.el8_3.x86_64           29/52',
                    '  Cleanup          : tar-2:1.30-4.el8.x86_64                               30/52',
                    '  Cleanup          : yum-4.2.23-4.el8.noarch                               31/52',
                    '  Cleanup          : python3-dnf-4.2.23-4.el8.noarch                        32/52',
                    '  Cleanup          : dnf-4.2.23-4.el8.noarch                                33/52',
                    '  Cleanup          : dnf-data-4.2.23-4.el8.noarch                           34/52',
                    '  Cleanup          : firewalld-python-0.9.3-4.el8.noarch                    35/52',
                    '  Cleanup          : python3-firewall-0.9.3-4.el8.noarch                    36/52',
                    '  Cleanup          : firewalld-0.9.3-4.el8.noarch                           37/52',
                    '  Cleanup          : firewalld-filesystem-0.9.3-4.el8.noarch                38/52',
                    '  Cleanup          : systemd-udev-239-41.el8_3.2.x86_64                    39/52',
                    '  Cleanup          : systemd-239-41.el8_3.2.x86_64                          40/52',
                    '  Cleanup          : systemd-pam-239-41.el8_3.2.x86_64                      41/52',
                    '  Cleanup          : systemd-libs-239-41.el8_3.2.x86_64                     42/52',
                    '  Cleanup          : python3-libs-3.6.8-34.el8.x86_64                       43/52',
                    '  Cleanup          : glibc-langpack-en-2.28-127.el8.x86_64                  44/52',
                    '  Cleanup          : glibc-2.28-127.el8.x86_64                              45/52',
                    '  Cleanup          : glibc-common-2.28-127.el8.x86_64                       46/52',
                    '  Cleanup          : tzdata-2020d-4.el8.noarch                             47/52',
                    '  Cleanup          : kernel-modules-4.18.0-240.22.1.el8_3.x86_64            48/52',
                    '  Cleanup          : kernel-core-4.18.0-240.22.1.el8_3.x86_64               49/52',
                    '  Cleanup          : kernel-4.18.0-240.22.1.el8_3.x86_64                    50/52',
                    '  Verifying        : dnf-4.4.2-11.el8_4.noarch                              51/52',
                    '  Verifying        : yum-4.4.2-11.el8_4.noarch                              52/52',
                    '',
                    'Updated:',
                    '  dnf-4.4.2-11.el8_4.noarch                      dnf-data-4.4.2-11.el8_4.noarch',
                    '  etcd-3.3.11-2.el8_4.x86_64                     firewalld-0.9.3-13.el8_4.noarch',
                    '  firewalld-filesystem-0.9.3-13.el8_4.noarch     firewalld-python-0.9.3-13.el8_4.noarch',
                    '  glibc-2.28-151.el8.x86_64                      glibc-common-2.28-151.el8.x86_64',
                    '  glibc-devel-2.28-151.el8.x86_64                glibc-headers-2.28-151.el8.x86_64',
                    '  glibc-langpack-en-2.28-151.el8.x86_64          kernel-4.18.0-305.3.1.el8_4.x86_64',
                    '  kernel-core-4.18.0-305.3.1.el8_4.x86_64        kernel-headers-4.18.0-305.3.1.el8_4.x86_64',
                    '  kernel-modules-4.18.0-305.3.1.el8_4.x86_64     python3-dnf-4.4.2-11.el8_4.noarch',
                    '  python3-firewall-0.9.3-13.el8_4.noarch         python3-libs-3.6.8-37.el8.x86_64',
                    '  systemd-239-45.el8_4.3.x86_64                  systemd-libs-239-45.el8_4.3.x86_64',
                    '  systemd-pam-239-45.el8_4.3.x86_64              systemd-udev-239-45.el8_4.3.x86_64',
                    '  tar-2:1.30-5.el8.x86_64                        tzdata-2021a-1.el8.noarch',
                    '  yum-4.4.2-11.el8_4.noarch',
                    '',
                    'Complete!'
                ];
                
                printOutputLineByLine(updateOutput, () => {
                    setTimeout(addPrompt, 1000);
                });
            }

            // 显示 yum install epel-release 输出
            function showYumInstallEpelOutput() {
                const installEpelOutput = [
                    'Last metadata expiration check: 0:10:34 ago on Mon 01 Jan 2024 12:10:00 AM UTC.',
                    'Dependencies resolved.',
                    '',
                    '================================================================================',
                    ' Package               Architecture Version                Repository        Size',
                    '================================================================================',
                    'Installing:',
                    ' epel-release          noarch       8-11.el8               extras            24 k',
                    '',
                    'Transaction Summary',
                    '================================================================================',
                    'Install  1 Package',
                    '',
                    'Total download size: 24 k',
                    'Installed size: 32 k',
                    'Downloading Packages:',
                    '[MIRROR] epel-release-8-11.el8.noarch.rpm: Downloading from centos.mirror.com',
                    '--------------------------------------------------------------------------------',
                    'Total                                           1.2 MB/s |  24 kB     00:00',
                    'Running transaction check',
                    'Transaction check succeeded.',
                    'Running transaction test',
                    'Transaction test succeeded.',
                    'Running transaction',
                    '  Preparing        :                                                        1/1',
                    '  Installing       : epel-release-8-11.el8.noarch                           1/1',
                    '  Verifying        : epel-release-8-11.el8.noarch                           1/1',
                    '',
                    'Installed:',
                    '  epel-release-8-11.el8.noarch',
                    '',
                    'Complete!'
                ];
                
                printOutputLineByLine(installEpelOutput, () => {
                    setTimeout(addPrompt, 1000);
                });
            }

            // 显示 yum install nginx 输出
            function showYumInstallNginxOutput() {
                const installNginxOutput = [
                    'Last metadata expiration check: 0:00:30 ago on Mon 01 Jan 2024 12:20:00 AM UTC.',
                    'Dependencies resolved.',
                    '',
                    '================================================================================',
                    ' Package               Architecture Version                Repository        Size',
                    '================================================================================',
                    'Installing:',
                    ' nginx                 x86_64       1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream         578 k',
                    'Installing dependencies:',
                    ' nginx-all-modules     noarch       1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream          24 k',
                    ' nginx-filesystem      noarch       1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream          24 k',
                    ' nginx-mod-http-image-filter x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream          35 k',
                    ' nginx-mod-http-perl   x86_64       1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream          48 k',
                    ' nginx-mod-http-xslt-filter x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream          35 k',
                    ' nginx-mod-mail        x86_64       1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream          59 k',
                    ' nginx-mod-stream      x86_64       1:1.14.1-9.module_el8.0.0+184+e34fea82  appstream          58 k',
                    '',
                    'Transaction Summary',
                    '================================================================================',
                    'Install  8 Packages',
                    '',
                    'Total download size: 861 k',
                    'Installed size: 2.2 M',
                    'Downloading Packages:',
                    '[MIRROR] nginx-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] nginx-all-modules-1.14.1-9.module_el8.0.0+184+e34fea82.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] nginx-filesystem-1.14.1-9.module_el8.0.0+184+e34fea82.noarch.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] nginx-mod-http-image-filter-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] nginx-mod-http-perl-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] nginx-mod-http-xslt-filter-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] nginx-mod-mail-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm: Downloading from centos.mirror.com',
                    '[MIRROR] nginx-mod-stream-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm: Downloading from centos.mirror.com',
                    '--------------------------------------------------------------------------------',
                    'Total                                           4.3 MB/s | 861 kB     00:00',
                    'Running transaction check',
                    'Transaction check succeeded.',
                    'Running transaction test',
                    'Transaction test succeeded.',
                    'Running transaction',
                    '  Preparing        :                                                        1/1',
                    '  Installing       : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch 1/8',
                    '  Installing       : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64   2/8',
                    '  Installing       : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 3/8',
                    '  Installing       : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 4/8',
                    '  Installing       : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 5/8',
                    '  Installing       : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 6/8',
                    '  Installing       : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 7/8',
                    '  Installing       : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch 8/8',
                    '  Running scriptlet: nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64   8/8',
                    '  Verifying        : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64   1/8',
                    '  Verifying        : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch 2/8',
                    '  Verifying        : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch 3/8',
                    '  Verifying        : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 4/8',
                    '  Verifying        : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 5/8',
                    '  Verifying        : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 6/8',
                    '  Verifying        : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 7/8',
                    '  Verifying        : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 8/8',
                    '',
                    'Installed:',
                    '  nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64',
                    '  nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch',
                    '  nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch',
                    '  nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64',
                    '  nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64',
                    '  nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64',
                    '  nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64',
                    '  nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64',
                    '',
                    'Complete!'
                ];
                
                printOutputLineByLine(installNginxOutput, () => {
                    setTimeout(() => {
                        addOutput('', '');
                        addOutput('Nginx has been successfully installed!', 'success');
                        addOutput('You can start Nginx with: systemctl start nginx', 'info');
                        addPrompt();
                    }, 1000);
                });
            }

            // 显示 systemctl start nginx 输出
            function showSystemctlStartNginxOutput() {
                const startOutput = [
                    '',
                    // 模拟启动时的短暂延迟和成功提示
                    'Starting nginx service...',
                    ''
                ];
                
                printOutputLineByLine(startOutput, () => {
                    setTimeout(() => {
                        addOutput('nginx.service - The nginx HTTP and reverse proxy server', 'info');
                        addOutput('   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)', 'info');
                        addOutput('   Active: active (running) since Mon 2024-01-01 12:22:30 UTC; 2s ago', 'success');
                        addOutput('     Docs: man:nginx(8)', 'info');
                        addOutput('  Process: 12345 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)', 'info');
                        addOutput(' Main PID: 12346 (nginx)', 'info');
                        addOutput('    Tasks: 2 (limit: 1152)', 'info');
                        addOutput('   Memory: 3.5M', 'info');
                        addOutput('   CGroup: /system.slice/nginx.service', 'info');
                        addOutput('           ├─12346 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf', 'info');
                        addOutput('           └─12347 nginx: worker process', 'info');
                        addOutput('', '');
                        addOutput('Jan 01 12:22:30 centos8 systemd[1]: Starting The nginx HTTP and reverse proxy server...', 'info');
                        addOutput('Jan 01 12:22:30 centos8 systemd[1]: Started The nginx HTTP and reverse proxy server.', 'success');
                        addOutput('', '');
                        
                        setTimeout(addPrompt, 1000);
                    }, 500);
                });
            }

            // 显示 systemctl status nginx 输出
            function showSystemctlStatusNginxOutput() {
                const statusOutput = [
                    '',
                    'nginx.service - The nginx HTTP and reverse proxy server',
                    '   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)',
                    '   Active: active (running) since Mon 2024-01-01 12:22:30 UTC; 1min 15s ago',
                    '     Docs: man:nginx(8)',
                    '  Process: 12345 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)',
                    ' Main PID: 12346 (nginx)',
                    '    Tasks: 2 (limit: 1152)',
                    '   Memory: 3.8M',
                    '   CGroup: /system.slice/nginx.service',
                    '           ├─12346 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf',
                    '           └─12347 nginx: worker process',
                    '',
                    'Jan 01 12:22:30 centos8 systemd[1]: Starting The nginx HTTP and reverse proxy server...',
                    'Jan 01 12:22:30 centos8 systemd[1]: Started The nginx HTTP and reverse proxy server.',
                    '',
                    'nginx is running successfully!',
                    ''
                ];
                
                printOutputLineByLine(statusOutput, () => {
                    setTimeout(addPrompt, 1000);
                });
            }

            // 逐行打印输出，模拟实时效果
            function printOutputLineByLine(lines, callback) {
                let i = 0;
                
                function printLine() {
                    if (i < lines.length) {
                        // 添加加载动画效果
                        if (lines[i].includes('[MIRROR]') || lines[i].includes('Downloading') || lines[i].includes('Running transaction')) {
                            addOutput(lines[i] + ' ... ', 'info');
                            const lastOutput = terminalBody.lastChild;
                            
                            let dots = 0;
                            const dotInterval = setInterval(() => {
                                dots = (dots + 1) % 4;
                                lastOutput.textContent = lines[i] + ' '.repeat(dots);
                                
                                if (dots === 3) {
                                    clearInterval(dotInterval);
                                    lastOutput.textContent = lines[i];
                                    i++;
                                    setTimeout(printLine, 100 + Math.random() * 200);
                                }
                            }, 200);
                        } else {
                            addOutput(lines[i]);
                            i++;
                            setTimeout(printLine, 50 + Math.random() * 100);
                        }
                    } else {
                        callback();
                    }
                }
                
                printLine();
            }

            // 启动终端
            initTerminal();
        });
    </script>
</body>
</html>
